package com.nstar.base.container
{
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.ui.Keyboard;
	
	import mx.containers.TitleWindow;
	import mx.events.CloseEvent;
	import mx.events.FlexEvent;
	import mx.managers.PopUpManager;

	public class TitleWindowFX extends TitleWindow
	{
		public function TitleWindowFX()
		{
			//TODO: implement function
			super();
			this.showCloseButton = true;
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
		}
		
		private function init(event:FlexEvent):void{
			
			this.addEventListener(CloseEvent.CLOSE,closeHandler);
			this.addEventListener(KeyboardEvent.KEY_DOWN,escapeHandler);
			this.setFocus();
		}
		
		protected function closeHandler(event:*):void{
			PopUpManager.removePopUp(this);
		}
		
		
		private function escapeHandler(event:KeyboardEvent):void{
			if (event.keyCode == Keyboard.ESCAPE){
				closeHandler(null);
			}
			
		}
		
	}
}